﻿using System;
using System.Configuration;
using System.Web.Configuration;

namespace VioletDevelopmentLaboratory.Net.Web.Configuration
{
	public sealed class VWebConfigurationManager
	{
		private VWebSection section;
		public VWebSection Section { get { return this.section; } }

		private System.Configuration.Configuration webConfig;

		private Boolean forceSaveAll;
		public Boolean ForceSaveAll { get { return this.forceSaveAll; } set { this.forceSaveAll = value; } }

		private ConfigurationSaveMode saveMode;
		public ConfigurationSaveMode SaveMode { get { return this.saveMode; } set { this.saveMode = value; } }

		public VWebConfigurationManager()
		{
			webConfig = WebConfigurationManager.OpenWebConfiguration("~/");
			this.section = (VWebSection)this.webConfig.GetSection("VWeb"); ;
			this.SaveMode = ConfigurationSaveMode.Minimal;
			this.ForceSaveAll = false;
		}

		public void Save()
		{
			this.webConfig.Save(SaveMode, ForceSaveAll);
		}
	}
}
